#pragma once
#include <QQuickPaintedItem>
#include <QImage>
#include <QPainter>
#include <QQuickView>
#include <QtSvg/QSvgRenderer>

class SvgImage : public QQuickPaintedItem
{
    Q_OBJECT
    Q_PROPERTY(QString source READ readSource WRITE writeSource NOTIFY sourceChanged)
public:
    explicit SvgImage(QQuickItem *parent = nullptr);

    static void declareQML();
    QString readSource() const { return m_source; };
    void writeSource(QString sourcePath);

signals:
    void sourceChanged();

protected:
    void paint(QPainter *painter) override;

private:
    QSvgRenderer *m_pSvgRenderer = nullptr;
    QString m_source = "";
};
